/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Old Developer team
 * @version 1.1
 */

package wads.app;

import wads.drawing.line.WADLink;
import wads.drawing.node.GateNode;
import wads.drawing.node.DatabaseNode;
import wads.drawing.CaseShape;
import wads.drawing.node.UserNode;
import java.awt.Cursor;
import java.awt.Point;
import java.awt.Toolkit;
import javax.swing.ImageIcon;

public class WADDiagramPanel extends DrawPanel {
//  private static final long serialVersionUID = -7595394269668516050L;
  
  private Toolkit tk = Toolkit.getDefaultToolkit();
  private ImageIcon nodeToolCursorImage = new ImageIcon("images/cursors/NodeToolCursor.gif");
  private ImageIcon linkToolCursorImage = new ImageIcon("images/cursors/LinkToolCursor.gif");
  private ImageIcon databaseToolCursorImage = new ImageIcon("images/cursors/DatabaseToolCursor.gif");
  //private ImageIcon groupToolCursorImage = new ImageIcon("images/cursors/GroupToolCursor.gif");
  private ImageIcon gateToolCursorImage = new ImageIcon("images/cursors/GateToolCursor.gif");
  
  public WADDiagramPanel(CaseEditor editor){
    super(editor);
  }

    @Override
  protected void setCurrentToolCursor(int toolkey) {
    switch(toolkey){
      case WADDiagramToolBar.NODE_TOOL:
        setCursor(tk.createCustomCursor(nodeToolCursorImage.getImage(), new Point(10, 10), "NodeToolCursor"));
        break;
      case WADDiagramToolBar.LINK_TOOL:
        setCursor(tk.createCustomCursor(linkToolCursorImage.getImage(), new Point(10, 10), "LinkToolCursor"));
        break;
      case WADDiagramToolBar.DATABASE_TOOL:
        setCursor(tk.createCustomCursor(databaseToolCursorImage.getImage(), new Point(10, 10), "DatabaseToolCursor"));
        break;
      case WADDiagramToolBar.GATE_TOOL:
        setCursor(tk.createCustomCursor(gateToolCursorImage.getImage(), new Point(10, 10), "GateToolCursor"));
        break;
      default:
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
  }

  @Override
  public CaseShape createCurrentShape(Point anchorPoint){
    int tool = caseEditor.getCurrentTool();
    switch(tool) {
      case WADDiagramToolBar.NODE_TOOL:
        return new UserNode(anchorPoint);
      case WADDiagramToolBar.LINK_TOOL:
        return new WADLink(anchorPoint);
      case WADDiagramToolBar.DATABASE_TOOL:
        return new DatabaseNode(anchorPoint);
//      case WADDiagramToolBar.GROUP_TOOL:
//        return new WADGroup(anchorPoint);
      case WADDiagramToolBar.GATE_TOOL:
        return new GateNode(anchorPoint);
      default:
        return null;
    }
  }

    @Override
  public boolean isCurrentToolaNode(){
    int tool = caseEditor.getCurrentTool();
    switch(tool){
      case WADDiagramToolBar.NODE_TOOL:
        return true;
      case WADDiagramToolBar.DATABASE_TOOL:
        return true;
      case WADDiagramToolBar.GATE_TOOL:
        return true;
    }
    return false;
  }

    @Override
  public boolean isCurrentToolaLink(){
    int tool = caseEditor.getCurrentTool();
    switch(tool){
      case WADDiagramToolBar.LINK_TOOL:
        return true;
    }
    return false;
  }
  
  @Deprecated
  @Override
  public boolean isCurrentToolaGroup(){
    int tool = caseEditor.getCurrentTool();
    switch(tool){
      case WADDiagramToolBar.GROUP_TOOL:
        return true;
    }
    return false;
  }
  
  public boolean isCurrentToolaGate() {
    int tool = caseEditor.getCurrentTool();
    if(tool == WADDiagramToolBar.GATE_TOOL) {
      return true;
    }
    else {
      return false;
    }
  }
}